#include "graphic_particle_modifier_life.h"

// .. REFERENCES

#include "graphic_particle_modifier.h"
#include "graphic_particle_table.h"

// -- PUBLIC

// .. CONSTRUCTORS

GRAPHIC_PARTICLE_MODIFIER_LIFE::GRAPHIC_PARTICLE_MODIFIER_LIFE() :
    GRAPHIC_PARTICLE_MODIFIER()
{
    Flags |= GRAPHIC_PARTICLE_SYSTEM::FLAG_UseLifeTime;
}

// .. OPERATIONS

VOID GRAPHIC_PARTICLE_MODIFIER_LIFE::Modify(
    GRAPHIC_PARTICLE_TABLE::FIXED_PARTICLE_TABLE & particle_table,
    const TIMER & time_step
    )
{
    INDEX
        particle_index;

    for_each_index( particle_index, GRAPHIC_PARTICLE_TABLE::FixedParticleCount )
    {
        particle_table.LifeTime[ particle_index ] -= time_step.GetSecondCount();

        if( particle_table.LifeTime[ particle_index ] <= 0.0f )
        {
            particle_table.Enabled[ particle_index ] = false;
        }
    }
}
